/*
 * hf_inj.h
 *
 *  Created on: Apr 1, 2024
 *      Author: Yiwen Zhu
 */

#ifndef SELF_DEFINE_HF_INJ_H_
#define SELF_DEFINE_HF_INJ_H_

#include "my_def.h"



typedef struct 	{ _iq  Uinj; 			// Input: Voltage of HFI
				  _iq  Ial;		// Parameter: Raw value of Ialpha
				  _iq  Ibe;		// Parameter: Raw value of Ialpha
				  _iq  Ial_last;		// Parameter: Raw value of Ibeta  at last period
				  _iq  Ibe_last;		// Parameter: Raw value of Ialpha at last period
				  _iq  Lpfal_last;
				  _iq  Lpfbe_last;
				  _iq  Ial_Low;			// Parameter: Current low frequency component in alpha axis
				  _iq  Ibe_Low;			// Parameter: Current low frequency component in beta axis
				  _iq  Ial_High;		// Parameter: Current high frequency component in alpha axis
				  _iq  Ibe_High;		// Parameter: Current high frequency component in beta axis
				  _iq  LPF_alpha;		// Input: alpha of a one-order LPF
				  char Inj_Sign;			// Parameter: Vinj(==1) or -Vinj(==0)
				  _iq  Theta;			// Output: Observed raw angle
				  _iq  Uout;
				  _iq  sin;
				  _iq  cos;
				  _iq  Kp;
				  _iq  Ki;
				  _iq  Up;
				  _iq  Ui;
				  _iq  Offset;
				} HFI;

typedef struct	{_iq Ta;
				_iq Tb;
				_iq Tc;
				_iq Ia;
				_iq Ib;
				_iq Ic;
				_iq Cur_buf[6];
				int Step;
				_iq Theta;
				_iq Init_Flag;

}SIX_PULES;


/*-----------------------------------------------------------------------------
Default initalizer for the SVGEN object.
-----------------------------------------------------------------------------*/
#define HFI_DEFAULTS {0}

void FHI_injection_task(void);
void HFI_calc_task(void);
char init_angle_meas(void);
char init_angle_pull(void);
#endif /* SELF_DEFINE_HF_INJ_H_ */
